package com.demo.designmode.builder.case2;

import com.demo.designmode.builder.case1.User;

public class UserBuilder {

    private User user;

    private UserBuilder() {
    }

    public static UserBuilder getInstance() {
        return new UserBuilder();
    }

    public UserBuilder newPojo() {
        this.user = new User();
        //返回本身
        return this;
    }

    public UserBuilder addId(String id) {
        this.user.setId(id);
        //返回本身
        return this;
    }

    public UserBuilder addName(String name) {
        this.user.setName(name);
        return this;
    }

    public UserBuilder addGender(String gender) {
        this.user.setGender(gender);
        return this;
    }

    public UserBuilder addAge(Integer age) {
        this.user.setAge(age);
        return this;
    }

    public UserBuilder addAddress(String address) {
        this.user.setAddress(address);
        return this;
    }

    public UserBuilder addPhone(String phone) {
        this.user.setPhone(phone);
        return this;
    }

    public User build() {
        return this.user;
    }
}